<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> 
<head>
<title>Remoting Sample</title>
<link rel="stylesheet" type="text/css" href="../../../docs/rotor.css">
</head>

<body>		


<h1> Remoting Sample</h1>


<h2>Sample Overview</h2>


<p>This sample demonstrates various aspects of the <b>System.Runtime.Remoting</b> 
namespace.&nbsp; </p>


<p>There are three elements to this sample:</p>


<ul>
  <li>Client:&nbsp; This is the client application that creates objects and 
  passes them to the server application.&nbsp; </li>
  <li>Server: This application waits for input from the client and responds.</li>
  <li>Shared: This library contains a shared object definition used by both 
  client and server applications.</li>
</ul>


<p>The server application supports the following user-specified options:</p>


<ul>
  <li>Communicate over HTTP, TCP, or both channels at the same time.&nbsp; This 
  must match what the client will use when opening channels to the server.</li>
  <li>Use either <b>SingleCall</b> or <b>Singleton</b> object modes.&nbsp; <b>SingleCall</b> destroys 
  the remoted object after each invocation.&nbsp; <b>Singleton</b> keeps the object 
  alive and reuses it for each invocation.</li>
  <li><b>ByRef</b> or <b>ByVal</b> calling convention.&nbsp; This must match what the client 
  will use to pass the remote object to the server.</li>
</ul>


<p>The client application supports the following user-specified options:</p>


<ul>
  <li>Communicate over HTTP, TCP, or both channels at the same time. This 
  must match the option used by the server or the channel will not open. If the option to use both channels is selected, then the client will use 
  threads to invoke the server. If either HTTP or TCP are specified then 
  the client will not use separate threads but will invoke the server from the 
  main thread.</li>
  <li>Pass <b>ByRef</b> or <b>ByVal</b> objects to the server. This option must match 
  the option used by the server or a exception will occur.</li>
  <li>Invoke the server sequentially or asynchronously.&nbsp; This is 
  client-side only behavior. It demonstrates two different ways of 
  implementing the server invocation.</li>
</ul>


<p>The shared library implements objects that are either <b>MarshalByRef</b> (for being 
passed by reference) or serializable (for being passed by value).&nbsp; The client 
and server applications switch between these object types depending on user input.</p>



<h2>Sample Source and Build Output Locations</h2>


<p>The sample source is found in sscli20\samples\howto\remoting in the client, 
server, and shared subdirectories.&nbsp; </p>


<p>The source files are:</p>


<ul class="none">
  <li><a href="client/client.cs">client\client.cs</a></li>
  <li><a href="server/server.cs">server\server.cs</a></li>
  <li><a href="shared/shared.cs">shared\shared.cs</a></li>
</ul>


<p>The build output location is %_NTTREE%\samples\howto\remoting.&nbsp; 
The output files are executable assemblies named remotingclient.exe and 
remotingserver.exe, and a library assembly named remotingshared.dll.</p>


<h2>Building the Sample</h2>


<p>All samples are built from the buildall script.&nbsp;  </p>


<p>You can also build all the 
samples by switching to the root of the sample directory, sscli20\samples, and typing 
<code>build -c</code>.</p>


<p>You can build this specific sample  by switching to the sample directory and typing 
<code>build -c</code>.</p>


<h2>Running the Sample</h2>


<p>These steps require that the Shared Source CLI (SSCLI) be already built and 
functional.</p>


<ol>
  <li>Run  env.bat. </li>
  <li>Switch to the %_NTTREE%\samples\howto\remoting directory.</li>
  <li>Type the following command:<blockquote>


<p>clix remotingserver</p>


  </blockquote>


  </li>
  <li>In another console window type:</li>
</ol>
<blockquote>
  <blockquote>


<p>clix remotingclient</p>


  </blockquote>
</blockquote>


<p>The sample applications will prompt you for optional values.&nbsp; Make sure that 
the client and server match input for object type (<b>ByVal</b> or <b>ByRef</b>) and 
communication channels.</p>


<hr>


<p><i>Copyright (c) 2006 Microsoft Corporation. All rights reserved.</i></p>
</body> 
</html>